package com.gexiaobao.pigeon.ui.dialog

import android.content.Context
import android.graphics.Color
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import androidx.appcompat.widget.AppCompatTextView
import com.gexiaobao.pigeon.R
import com.gexiaobao.pigeon.app.ext.RxTextTool

/**
 * @author:hxw
 * @date  :2022/12/8
 * @desc  :
 */
class RxDialogSingle(context: Context?) : RxDialog(context!!) {

    private lateinit var sureView: AppCompatTextView
    private lateinit var titleView: AppCompatTextView

    init {
        initView()
    }

    private fun initView() {
        val dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_single, null)
        sureView = dialogView.findViewById(R.id.tv_dialog_sure)
        titleView = dialogView.findViewById(R.id.tv_default_dialog_title)
        setContentView(dialogView)
    }

    fun setSureText(text: String) {
        if (text.isEmpty()) {
            return
        }
        sureView.text = text
    }

    fun setSureListener(listener: View.OnClickListener?) {
        sureView.setOnClickListener(listener)
    }

    fun setRightBtnContent(textRight: String) {
        if (textRight.isEmpty()) {
            return
        }
        sureView.text = textRight
    }

    fun setTitle(titleStr: String) {
        if (titleStr.isEmpty()) {
            titleView.visibility = View.GONE
            return
        }
        titleView.text = titleStr
        titleView.visibility = View.VISIBLE
        titleView.text = titleStr
    }

}